package com.ycw.cs.common.response;

import com.ycw.cs.common.enums.ResponseCode;

import java.util.List;

/**
 * 统一的应答结果,controller方法返回给View页面的数据都是它
 */

public class ResponseResults {

    /**
     * 应答码
     */
    private int code;
    /**
     * 应答消息
     */
    private String codeMsg;
    /**
     * 应答的数据
     */
    private Object data;
    /**
     * 用于存放集合数据
     */
    private List list;
    /**
     * 用于分页的类
     */
    private PageInfo pageInfo;
    /**
     *用来保存登录验证时的json web token
     */
    private String accessToken;

    public static ResponseResults ok(){
        ResponseResults responseResults=new ResponseResults();
        responseResults.setResponseCode(ResponseCode.SUCCESS);
        return responseResults;
    }

    public static ResponseResults fail(){
        ResponseResults responseResults=new ResponseResults();
        responseResults.setResponseCode(ResponseCode.FAIL);
        return responseResults;
    }

    public void setResponseCode(ResponseCode responseCode){
           this.code=responseCode.getCode();
           this.codeMsg=responseCode.getMsg();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getCodeMsg() {
        return codeMsg;
    }

    public void setCodeMsg(String codeMsg) {
        this.codeMsg = codeMsg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

    public PageInfo getPageInfo() {
        return pageInfo;
    }

    public void setPageInfo(PageInfo pageInfo) {
        this.pageInfo = pageInfo;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
}
